﻿using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;

namespace Tszy.Unlimited.AspNetCore.Extensions;

internal static class CorsExtensions
{
    public static void RegisterCors(this IServiceCollection services)
    {
        #region 配置跨域

        services.AddCors(options =>
        {
            options.AddPolicy("any", builder => { builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader(); });
        });

        #endregion 配置跨域
    }

    public static void UseCors(this WebApplication app)
    {
        app.UseCors("any");
    }
}